package com.nextel.project.pedido.bean;
import pe.com.nextel.rms.DataInputStreamX;
import pe.com.nextel.rms.DataOutputStreamX;
import pe.com.nextel.rms.PersistenteX;
import java.io.IOException;
import org.kxml2.io.KXmlParser;
import org.kxml2.io.KXmlSerializer;
import pe.com.nextel.util.ArrayList;
import pe.com.nextel.util.Iterator;
import pe.com.nextel.util.List;
import pe.com.nextel.util.StringUtils;
/**
 *
 * @author nexteldata
 */

public class LPrecioBean extends PersistenteX {
    private String codigoCanal;
    private String precio;

   public void persistir(DataOutputStreamX dataOutput, List list) throws IOException {
        //  System.out.println("PrecioBean.persistir");

        dataOutput.writeInt(list.size());

        for (Iterator it = list.iterator(); it.hasNext();) {
            LPrecioBean bean = (LPrecioBean) it.next();
            bean.persistirItem(dataOutput);
        }

    }

    public void persistirItem(DataOutputStreamX dataOutput) throws IOException {
        dataOutput.writeString(StringUtils.stringNullToBlank(getCodigoCanal()));
        dataOutput.writeString(StringUtils.stringNullToBlank(getPrecio()));
    }

    public void recuperarItem(DataInputStreamX dataInput) throws IOException {
        setCodigoCanal(dataInput.readString());
        setPrecio(dataInput.readString());
    }

    public List recuperar(DataInputStreamX dataInput) throws IOException {

        List lista = new ArrayList();
        LPrecioBean bean = null;

        int cant = dataInput.readInt();
        //System.out.println("cant=" + cant);
        for (int i = 0; i < cant; i++) {
            bean = new LPrecioBean();
            bean.recuperarItem(dataInput);
            lista.add(bean);
        }

        return lista;
    }

    public void writeXMLObject(KXmlSerializer writer) throws IOException {
    }

    public void readXMLObject(KXmlParser parser) throws IOException {
        setCodigoCanal(parser.getAttributeValue(null, "cc"));
        setPrecio(parser.getAttributeValue(null, "p"));

    }

    public String getCodigoCanal() {
        return codigoCanal;
    }

    public void setCodigoCanal(String codigoCanal) {
        this.codigoCanal = codigoCanal;
    }

    public String getPrecio() {
        return precio;
    }

    public void setPrecio(String precio) {
        this.precio = precio;
    }

   
   
}
